home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d1
/
bastips2.arc
/
BASANSI.TXT
next >
Wrap
Text File
|
1988-11-29
|
2KB
|
58 lines
Accessing the ANSI Driver from BASIC
(BYTE Magazine November 1986 Best of BIX)
You can access the ANSI driver from BASIC. You should have the
system boot with the statement:
DEVICE=[D][PATH]ANSI.SYS
in your CONFIG.SYS file. To access the driver from BASIC (or any
language) all you have to do is write to the device "CON," which
happens to be stdout. The driver that you install in your CONFIG.SYS
file will take precedence over the "Glass TTY" console driver that DOS
installs.
The statement, OPEN "CON" FOR OUTPUT AS #1, will open the stdout
file for writing. The statement, PRINT #1, "Hello", will print the
word Hello at the current cursor position and also issue a carriage
return line feed sequence.
The complete subset that the ANSI.SYS driver supports is available
to you through the PRINT #1 statement. The supported escape sequences
are listed in the DOS Technical Reference Manual.
For example, suppose you wish to clear the screen, then position
the cursor at line 12, column 20 and print the string "Enter Your Name
Please:". The following example will do just that:
10 OPEN "CON" FOR OUTPUT AS #1
20 PRINT #1, CHR$(27);"[2J";
30 PRINT #1, CHR$(27);"[12;20H";
40 PRINT #1, "Enter Your Name Please:";
50 CLOSE #1
Line 10 will open the console device for writing. Line 20 will clear
the screen. Line 30 will position the cursor at row 12, column 20.
Line 40 will print the string. Line 50 will close the file. Note
that the characters are case-sensitive.
The following set of commands allows screen manipulation.
10 OPEN "CON" FOR OUTPUT AS #1
20 ETB$=CHR$(27)+"[s"
25 FOR X=1 TO 24:ETB$=ETB$+CHR$(27)+"[k"+CHR$(27)+"[B":NEXT X
30 ETB$=ETB$+CHR$(27)+"[u"
40 ENQ$=CHR$(27)+"[s"+CHR$(27)+"[K"+CHR$(270"+[u"
You can now clear the screen to the bottom at any time by locating at
the position to clear from and:
PRINT #1,ETB$
Notice that line 20 includes the cursor position save function as the
first part of the clear to end of screen function. Line 30 then
returns to the original cursor position. To clear a single line to
the end, just:
PRINT #1,ENQ$
The characters are case-sensitive.